//    Copyright (C) Kherty.  All rights reserved.
using System;
using OpenLS.Core.Serialization;
using OpenLS.Vml.Serialization;

namespace OpenLS.Vml.Spreadsheet
{
    public class ClientData: ShapeElement
    {
        internal const string xmlName = "ClientData";
        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read(VmlConstants.ExcelNamespace + xmlName))
            {
                ObjectType = c.GetEnum<ObjectType>("ObjectType");
                while (c.ReaderLocalName != null)
                {
                    switch (c.ReaderLocalName)
                    {
                        case "MoveWithCells":
                            MoveWithCells = readTrueFalseBlank(c, "MoveWithCells");
                            break;
                        case "SizeWithCells":
                            SizeWithCells = readTrueFalseBlank(c, "SizeWithCells");
                            break;
                        case "Anchor":
                            Anchor = c.ReadElementString("Anchor"); break;
                        case "AutoFill":
                            AutoFill = readTrueFalseBlank(c, "AutoFill"); break;
                        case "Row":
                            Row = int.Parse(c.ReadElementString("Row")); break;
                        case "Column":
                            Column = int.Parse(c.ReadElementString("Column")); break;
                        case "CF":
                            ClipboardFormat = c.ReadElementEnum<ClipboardFormat>("CF", VmlConstants.ExcelNamespaceUri); break;
                        case "Visible":
                            Visible = readTrueFalseBlank(c, "Visible"); break;
                        case "Locked":
                            Locked = readTrueFalseBlank(c, "Locked"); break;
                        case "PrintObject":
                            PrintObject = readTrueFalseBlank(c, "PrintObject"); break;
                        case "AutoLine":
                            AutoLine = readTrueFalseBlank(c, "AutoLine"); break;
                        case "FmlaLink":
                            FormulaLink = c.ReadElementString("FmlaLink"); break;
                        case "Val":
                            Val = int.Parse(c.ReadElementString("Val")); break;
                        case "Min":
                            Min = int.Parse(c.ReadElementString("Min")); break;
                        case "Max":
                            Max = int.Parse(c.ReadElementString("Max")); break;
                        case "Inc":
                            Inc = int.Parse(c.ReadElementString("Inc")); break;
                        case "Page":
                            Page = int.Parse(c.ReadElementString("Page")); break;
                        case "DefaultSize":
                            DefaultSize = c.ReadElementString("DefaultSize"); break;
                        case "Disabled":
                            Disabled = c.ReadElementString("Disabled"); break;
                        case "AutoPict":
                            AutoPict = c.ReadElementString("AutoPict"); break;
                        case "FmlaMacro":
                            FmlaMacro = c.ReadElementString("FmlaMacro"); break;
                        case "TextHAlign":
                            TextHAlign = c.ReadElementString("TextHAlign"); break;
                        case "TextVAlign":
                            TextVAlign = c.ReadElementString("TextVAlign"); break;
                        case "LockText":
                            LockText = c.ReadElementString("LockText"); break;
                        case "JustLastX":
                            JustLastX = c.ReadElementString("JustLastX"); break;
                        case "SecretEdit":
                            SecretEdit = c.ReadElementString("SecretEdit"); break;
                        case "Default":
                            Default = c.ReadElementString("Default"); break;
                        case "Help":
                            Help = c.ReadElementString("Help"); break;
                        case "Cancel":
                            Cancel = c.ReadElementString("Cancel"); break;
                        case "Dismiss":
                            Dismiss = c.ReadElementString("Dismiss"); break;
                        case "Accel":
                            Accel = c.ReadElementString("Accel"); break;
                        case "Accel2":
                            Accel2 = c.ReadElementString("Accel2"); break;
                        case "RowHidden":
                            RowHidden = c.ReadElementString("RowHidden"); break;
                        case "ColHidden":
                            ColHidden = c.ReadElementString("ColHidden"); break;
                        case "VTEdit":
                            VTEdit = c.ReadElementString("VTEdit"); break;
                        case "MultiLine":
                            MultiLine = c.ReadElementString("MultiLine"); break;
                        case "VScroll":
                            VScroll = c.ReadElementString("VScroll"); break;
                        case "ValidIds":
                            ValidIds = c.ReadElementString("ValidIds"); break;
                        case "FmlaRange":
                            FmlaRange = c.ReadElementString("FmlaRange"); break;
                        case "WidthMin":
                            WidthMin = c.ReadElementString("WidthMin"); break;
                        case "Sel":
                            Sel = c.ReadElementString("Sel"); break;
                        case "NoThreeD2":
                            NoThreeD2 = c.ReadElementString("NoThreeD2"); break;
                        case "SelType":
                            SelType = c.ReadElementString("SelType"); break;
                        case "MultiSel":
                            MultiSel = c.ReadElementString("MultiSel"); break;
                        case "LCT":
                            LCT = c.ReadElementString("LCT"); break;
                        case "ListItem":
                            ListItem = c.ReadElementString("ListItem"); break;
                        case "DropStyle":
                            DropStyle = c.ReadElementString("DropStyle"); break;
                        case "Colored":
                            Colored = c.ReadElementString("Colored"); break;
                        case "DropLines":
                            DropLines = c.ReadElementString("DropLines"); break;
                        case "Checked":
                            Checked = c.ReadElementString("Checked"); break;
                        case "FmlaPict":
                            FmlaPict = c.ReadElementString("FmlaPict"); break;
                        case "NoThreeD":
                            NoThreeD = c.ReadElementString("NoThreeD"); break;
                        case "FirstButton":
                            FirstButton = c.ReadElementString("FirstButton"); break;
                        case "FmlaGroup":
                            FmlaGroup = c.ReadElementString("FmlaGroup"); break;
                        case "Horiz":
                            Horiz = c.ReadElementString("Horiz"); break;
                        case "Dx":
                            Dx = c.ReadElementString("Dx"); break;
                        case "MapOCX":
                            MapOCX = c.ReadElementString("MapOCX"); break;
                        case "Camera":
                            Camera = c.ReadElementString("Camera"); break;
                        case "RecalcAlways":
                            RecalcAlways = c.ReadElementString("RecalcAlways"); break;
                        case "AutoScale":
                            AutoScale = c.ReadElementString("AutoScale"); break;
                        case "DDE":
                            DDE = c.ReadElementString("DDE"); break;
                        case "UIObj":
                            UIObj = c.ReadElementString("UIObj"); break;
                        case "ScriptText":
                            ScriptText = c.ReadElementString("ScriptText"); break;
                        case "ScriptExtended":
                            ScriptExtended = c.ReadElementString("ScriptExtended"); break;
                        case "ScriptLanguage":
                            ScriptLanguage = c.ReadElementString("ScriptLanguage"); break;
                        case "ScriptLocation":
                            ScriptLocation = c.ReadElementString("ScriptLocation"); break;
                        case "FmlaTxbx":
                            FmlaTxbx = c.ReadElementString("FmlaTxbx"); break;
                        default:
                            throw new NotSupportedException();
                    }
                }
            }
        }

        private static bool readTrueFalseBlank(ReadContext c, string p)
        {
            string s = c.ReadElementString(p);
            switch (s.ToLower())
            {
                case "t":
                case "true":
                    return true;
                case "f":
                case "false":
                case "":
                    return false;
                default:
                    throw new NotSupportedException();
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write(VmlConstants.ExcelNamespace + xmlName))
            {
                c.SetEnum("ObjectType",ObjectType);
                WriteTrueFalseBlank (c, "MoveWithCells", MoveWithCells);
                WriteTrueFalseBlank (c, "SizeWithCells", SizeWithCells);
                c.WriteOptionalElementString("Anchor", Anchor);
                WriteTrueFalseBlank(c, "AutoFill", AutoFill);
                c.WriteOptionalElementString("Row", Row != null?Row.ToString(): null);
                c.WriteOptionalElementString("Column", Column != null?Column.ToString(): null);
                if (ClipboardFormat != null)
                    c.WriteElementEnum("CF", ClipboardFormat.Value);
                WriteTrueFalseBlank(c, "Visible", Visible);
                WriteTrueFalseBlank(c, "Locked", Locked);
                WriteTrueFalseBlank(c, "PrintObject", PrintObject);
                WriteTrueFalseBlank(c, "AutoLine", AutoLine);
                WriteTrueFalseBlank(c, "AutoLine", AutoLine);
                c.WriteOptionalElementString( "FmlaLink", FormulaLink);
                c.WriteOptionalElementString("Val", (Val!= null)?Val.Value.ToString():null);
                c.WriteOptionalElementString("Min", Min != null?Min.ToString():null);
                c.WriteOptionalElementString("Max", Max != null?Max.ToString():null);
                c.WriteOptionalElementString("Inc", Inc != null?Inc.ToString():null);
                c.WriteOptionalElementString("Page", Page != null?Page.ToString():null);
                c.WriteOptionalElementString( "DefaultSize", DefaultSize);
                c.WriteOptionalElementString( "Disabled", Disabled);
                c.WriteOptionalElementString( "AutoPict", AutoPict);
                c.WriteOptionalElementString( "FmlaMacro", FmlaMacro);
                c.WriteOptionalElementString( "TextHAlign", TextHAlign);
                c.WriteOptionalElementString( "TextVAlign", TextVAlign);
                c.WriteOptionalElementString( "LockText", LockText);
                c.WriteOptionalElementString( "JustLastX", JustLastX);
                c.WriteOptionalElementString( "SecretEdit", SecretEdit);
                c.WriteOptionalElementString( "Default", Default);
                c.WriteOptionalElementString( "Help", Help);
                c.WriteOptionalElementString( "Cancel", Cancel);
                c.WriteOptionalElementString( "Dismiss", Dismiss);
                c.WriteOptionalElementString( "Accel", Accel);
                c.WriteOptionalElementString( "Accel2", Accel2);
                c.WriteOptionalElementString( "RowHidden", RowHidden);
                c.WriteOptionalElementString( "ColHidden", ColHidden);
                c.WriteOptionalElementString( "VTEdit", VTEdit);
                c.WriteOptionalElementString( "MultiLine", MultiLine);
                c.WriteOptionalElementString( "VScroll", VScroll);
                c.WriteOptionalElementString( "ValidIds", ValidIds);
                c.WriteOptionalElementString( "FmlaRange", FmlaRange);
                c.WriteOptionalElementString( "WidthMin", WidthMin);
                c.WriteOptionalElementString( "Sel", Sel);
                c.WriteOptionalElementString( "NoThreeD2", NoThreeD2);
                c.WriteOptionalElementString( "SelType", SelType);
                c.WriteOptionalElementString( "MultiSel", MultiSel);
                c.WriteOptionalElementString( "LCT", LCT);
                c.WriteOptionalElementString( "ListItem", ListItem);
                c.WriteOptionalElementString( "DropStyle", DropStyle);
                c.WriteOptionalElementString( "Colored", Colored);
                c.WriteOptionalElementString( "DropLines", DropLines);
                c.WriteOptionalElementString( "Checked", Checked);
                c.WriteOptionalElementString( "FmlaPict", FmlaPict);
                c.WriteOptionalElementString( "NoThreeD", NoThreeD);
                c.WriteOptionalElementString( "FirstButton", FirstButton);
                c.WriteOptionalElementString( "FmlaGroup", FmlaGroup);
                c.WriteOptionalElementString( "Horiz", Horiz);
                c.WriteOptionalElementString( "Dx", Dx);
                c.WriteOptionalElementString( "MapOCX", MapOCX);
                c.WriteOptionalElementString( "Camera", Camera);
                c.WriteOptionalElementString( "RecalcAlways", RecalcAlways);
                c.WriteOptionalElementString( "AutoScale", AutoScale);
                c.WriteOptionalElementString( "DDE", DDE);
                c.WriteOptionalElementString( "UIObj", UIObj);
                c.WriteOptionalElementString( "ScriptText", ScriptText);
                c.WriteOptionalElementString( "ScriptExtended", ScriptExtended);
                c.WriteOptionalElementString( "ScriptLanguage", ScriptLanguage);
                c.WriteOptionalElementString( "ScriptLocation", ScriptLocation);
                c.WriteOptionalElementString( "FmlaTxbx", FmlaTxbx);
                    
                
            }
        }

        private static void WriteTrueFalseBlank(WriteContext c, string elementName, bool? value)
        {
            if (value == null)
                return;
            if (!value.Value)
                return;
            c.WriteElementString(elementName, "true");
            //\\ c.WriteElementString(elementName, value.Value ? "true" : "false"); //\\cap OK?
        }

        private ClipboardFormat? _cf;

        public ClipboardFormat? ClipboardFormat
        {
            get { return _cf; }
            set { _cf = value; }
        }

        private bool? _locked;

        public bool? Locked
        {
            get { return _locked; }
            set { _locked = value; }
        }
        private bool? _printObject;

        public bool? PrintObject
        {
            get { return _printObject; }
            set { _printObject = value; }
        }
        private bool? _autoLine;

        public bool? AutoLine
        {
            get { return _autoLine; }
            set { _autoLine = value; }
        }

        private string _fmlaLink;

        public string FormulaLink
        {
            get { return _fmlaLink; }
            set { _fmlaLink = value; }
        }
        private int? _val;

        public int? Val
        {
            get { return _val; }
            set { _val = value; }
        }
        private int? _min;

        public int? Min
        {
            get { return _min; }
            set { _min = value; }
        }
        private int? _max;

        public int? Max
        {
            get { return _max; }
            set { _max = value; }
        }
        private int? _inc;

        public int? Inc
        {
            get { return _inc; }
            set { _inc = value; }
        }
        private int? _page;

        public int? Page
        {
            get { return _page; }
            set { _page = value; }
        }
	
	
	
	
	
	
	
	

        private bool _moveWithCells;

        public bool MoveWithCells
        {
            get { return _moveWithCells; }
            set { _moveWithCells = value; }
        }
        private bool _sizeWithCells;

        public bool SizeWithCells
        {
            get { return _sizeWithCells; }
            set { _sizeWithCells = value; }
        }
        private string _anchor;

        public string Anchor
        {
            get { return _anchor; }
            set { _anchor = value; }
        }
        private bool _autoFill;

        public bool AutoFill
        {
            get { return _autoFill; }
            set { _autoFill = value; }
        }

        private int? _row;

        public int? Row
        {
            get { return _row; }
            set { _row = value; }
        }
        private int? _column;

        public int? Column
        {
            get { return _column; }
            set { _column = value; }
        }

        private bool _visible;

        public bool Visible
        {
            get { return _visible; }
            set { _visible = value; }
        }
	
	
	
	
	
        private ObjectType _objectType;

        public ObjectType ObjectType
        {
            get { return _objectType; }
            set { _objectType = value; }
        }

        private string _defaultSize;

        public string DefaultSize
        {
            get { return _defaultSize; }
            set { _defaultSize = value; }
        }
        private string _disabled;

        public string Disabled
        {
            get { return _disabled; }
            set { _disabled = value; }
        }
        private string _autoPict;

        public string AutoPict
        {
            get { return _autoPict; }
            set { _autoPict = value; }
        }

        private string _fmlaMacro;

        public string FmlaMacro
        {
            get { return _fmlaMacro; }
            set { _fmlaMacro = value; }
        }
        private string _textHAlign;

        public string TextHAlign
        {
            get { return _textHAlign; }
            set { _textHAlign = value; }
        }
        private string _textVAlign;

        public string TextVAlign
        {
            get { return _textVAlign; }
            set { _textVAlign = value; }
        }
        private string _lockText;

        public string LockText
        {
            get { return _lockText; }
            set { _lockText = value; }
        }
        private string _justLastX;

        public string JustLastX
        {
            get { return _justLastX; }
            set { _justLastX = value; }
        }
        private string _secretEdit;

        public string SecretEdit
        {
            get { return _secretEdit; }
            set { _secretEdit = value; }
        }
        private string _default;

        public string Default
        {
            get { return _default; }
            set { _default = value; }
        }
        private string _help;

        public string Help
        {
            get { return _help; }
            set { _help = value; }
        }
        private string _cancel;

        public string Cancel
        {
            get { return _cancel; }
            set { _cancel = value; }
        }
        private string _dismiss;

        public string Dismiss
        {
            get { return _dismiss; }
            set { _dismiss = value; }
        }
        private string _accel;

        public string Accel
        {
            get { return _accel; }
            set { _accel = value; }
        }
        private string _accel2;

        public string Accel2
        {
            get { return _accel2; }
            set { _accel2 = value; }
        }
        private string _rowHidden;

        public string RowHidden
        {
            get { return _rowHidden; }
            set { _rowHidden = value; }
        }
        private string _colHidden;

        public string ColHidden
        {
            get { return _colHidden; }
            set { _colHidden = value; }
        }
        private string _vtEdit;

        public string VTEdit
        {
            get { return _vtEdit; }
            set { _vtEdit = value; }
        }
        private string _multiLine;

        public string MultiLine
        {
            get { return _multiLine; }
            set { _multiLine = value; }
        }
        private string _vScroll;

        public string VScroll
        {
            get { return _vScroll; }
            set { _vScroll = value; }
        }
        private string _validIds;

        public string ValidIds
        {
            get { return _validIds; }
            set { _validIds = value; }
        }
        private string _fmlaRange;

        public string FmlaRange
        {
            get { return _fmlaRange; }
            set { _fmlaRange = value; }
        }
        private string _widthMin;

        public string WidthMin
        {
            get { return _widthMin; }
            set { _widthMin = value; }
        }
        private string _sel;

        public string Sel
        {
            get { return _sel; }
            set { _sel = value; }
        }
        private string _noThreeD2;

        public string NoThreeD2
        {
            get { return _noThreeD2; }
            set { _noThreeD2 = value; }
        }
        private string _selType;

        public string SelType
        {
            get { return _selType; }
            set { _selType = value; }
        }
        private string _multiSel;

        public string MultiSel
        {
            get { return _multiSel; }
            set { _multiSel = value; }
        }
	
        private string _lct;

        public string LCT
        {
            get { return _lct; }
            set { _lct = value; }
        }
        private string _listItem;

        public string ListItem
        {
            get { return _listItem; }
            set { _listItem = value; }
        }
        private string _dropStyle;

        public string DropStyle
        {
            get { return _dropStyle; }
            set { _dropStyle = value; }
        }
        private string _colored;

        public string Colored
        {
            get { return _colored; }
            set { _colored = value; }
        }
        private string _dropLines;

        public string DropLines
        {
            get { return _dropLines; }
            set { _dropLines = value; }
        }
        private string _checked;

        public string Checked
        {
            get { return _checked; }
            set { _checked = value; }
        }
        private string _fmlaPict;

        public string FmlaPict
        {
            get { return _fmlaPict; }
            set { _fmlaPict = value; }
        }
        private string _noThreeD;

        public string NoThreeD
        {
            get { return _noThreeD; }
            set { _noThreeD = value; }
        }
        private string _firstButton;

        public string FirstButton
        {
            get { return _firstButton; }
            set { _firstButton = value; }
        }
        private string _fmlaGroup;

        public string FmlaGroup
        {
            get { return _fmlaGroup; }
            set { _fmlaGroup = value; }
        }
        private string _horiz;

        public string Horiz
        {
            get { return _horiz; }
            set { _horiz = value; }
        }
        private string _dx;

        public string Dx
        {
            get { return _dx; }
            set { _dx = value; }
        }
        private string _mapOCX;

        public string MapOCX
        {
            get { return _mapOCX; }
            set { _mapOCX = value; }
        }
        private string _camera;

        public string Camera
        {
            get { return _camera; }
            set { _camera = value; }
        }
        private string _recalcAlways;

        public string RecalcAlways
        {
            get { return _recalcAlways; }
            set { _recalcAlways = value; }
        }
        private string _autoScale;

        public string AutoScale
        {
            get { return _autoScale; }
            set { _autoScale = value; }
        }
        private string _dde;

        public string DDE
        {
            get { return _dde; }
            set { _dde = value; }
        }
        private string _uiObj;

        public string UIObj
        {
            get { return _uiObj; }
            set { _uiObj = value; }
        }
        private string _scriptText;

        public string ScriptText
        {
            get { return _scriptText; }
            set { _scriptText = value; }
        }
        private string _scriptExtended;

        public string ScriptExtended
        {
            get { return _scriptExtended; }
            set { _scriptExtended = value; }
        }
        private string _scriptLanguage;

        public string ScriptLanguage
        {
            get { return _scriptLanguage; }
            set { _scriptLanguage = value; }
        }
        private string _scriptLocation;

        public string ScriptLocation
        {
            get { return _scriptLocation; }
            set { _scriptLocation = value; }
        }
        private string _fmlaTxbx;

        public string FmlaTxbx
        {
            get { return _fmlaTxbx; }
            set { _fmlaTxbx = value; }
        }
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
    }
}